<!doctype html>
<!--[if gt IE 8]><!--> <html class="no-js" lang=""> <!--<![endif]-->
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>教师端班级学生信息</title>
    <meta name="description" content="Ela Admin - HTML5 Admin Template">
    <meta name="viewport" content="width=device-width, initial-scale=1">
	
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/normalize.css@8.0.0/normalize.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.1.3/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/font-awesome@4.7.0/css/font-awesome.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/lykmapipo/themify-icons@0.1.2/css/themify-icons.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/pixeden-stroke-7-icon@1.2.3/pe-icon-7-stroke/dist/pe-icon-7-stroke.min.css">
    <link rel="stylesheet" href="assets/css/cs-skin-elastic.css">
    <link rel="stylesheet" href="assets/css/lib/datatable/dataTables.bootstrap.min.css">
    <link rel="stylesheet" href="assets/css/style.css">

    <!-- <script type="text/javascript" src="https://cdn.jsdelivr.net/html5shiv/3.7.3/html5shiv.min.js"></script> -->
	<script src="assets/js/vue.min.js" type="text/javascript" charset="utf-8"></script>
	<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.20.0/axios.min.js"></script>
</head>
<body>
    <!-- Left Panel -->

    <aside id="left-panel" class="left-panel">
       <nav class="navbar navbar-expand-sm navbar-default">
       
               <div id="main-menu" class="main-menu collapse navbar-collapse">
                   <ul class="nav navbar-nav">
                       
                       <li class="menu-title">菜单</li><!-- /.menu-title -->
                       <li>
                           <a href="tea-dataOfClass.html"> <i class="menu-icon fa fa-users"></i>班级 </a>
                       </li>
       				<li>
       				    <a href="tea-dataOfStudent.html"> <i class="menu-icon fa fa-file-word-o"></i>班级学生信息 </a>
       				</li>
					<li>
					    <a href="tea-updateHomework.html"> <i class="menu-icon fa fa-file-word-o"></i>插入新的一轮作业 </a>
					</li>
                       <li class="menu-title">退出</li><!-- /.menu-title -->
                       <li>
                           <a href="loginteacher.html"> <i class="menu-icon fa fa-user-o"></i>退出登录 </a>
                       </li>
                   </ul>
               </div><!-- /.navbar-collapse -->
           </nav>
        </aside><!-- /#left-panel -->

    <!-- Left Panel -->

    <!-- Right Panel -->

    <div id="right-panel" class="right-panel">

        <!-- Header-->
        <header id="header" class="header">
            <div class="top-left">
                <div class="navbar-header">
                    <a class="navbar-brand" href="#"><i class="menu-icon fa fa-user-circle fa-2x"></i></a>
					
                </div>
            </div>
          
        </header><!-- /header -->
        <!-- Header-->

        <div class="breadcrumbs">
            <div class="breadcrumbs-inner">
                <div class="row m-0">
                    
                    
                </div>
            </div>
        </div>

        <div class="content" id="stuapp">
			
            <div class="animated fadeIn">
                <div class="row">

                    <div class="col-md-12">
                        <div class="card">
                            <div class="card-header">
                                <strong class="card-title">课堂学生信息</strong>
                            </div>
                            <div class="card-body" >
								
								<br>
                                <table id="bootstrap-data-table" class="table table-striped table-bordered">
											<span class="badge badge-info">当前选中的班级：{{currentclass}}</span>
											
                                    <thead>
                                        <tr>
                                            <th>学生编号</th>
                                            <th>学生姓名</th>
                                            <th>学生学号</th>
                                            <th>本门课的分数</th>
											<th>选择批改</th>
                                        </tr>
                                    </thead>
                                    <tbody >
                                        <tr v-for="(i,index) in studatas">
                                            <td>{{i.sid}}</td>
                                            <td>{{i.sname}}</td>
                                            <td>{{i.susername}}</td>
                                            <td>{{i.score_information.average}}</td>
											<td>
												<input class="btn btn-success" type="button" value="Select" @click="SelectStudent(i.susername,i.sname)">
											</td>
                                        </tr>
                                        
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>


                </div>
            </div><!-- .animated -->
        </div><!-- .content -->


        <!-- /#right-panel -->

    <!-- Right Panel -->





<script type="text/javascript">
	let vm=new Vue({
		el:'#stuapp',
		data:{
			studatas:[],
			currentclass:window.localStorage.getItem('TselectClassName'),
			name:window.localStorage.getItem('TUsername')
		},
		mounted(){
			this.GetNewPages();
		},
		methods:{
			SelectStudent(sid,name){
				//alert('现在你选择的学生是：'+sid);//验证选择
				window.localStorage.setItem('TselectStudentName',name);
				window.localStorage.setItem('TselectStudent',sid);//存储cid
				window.location.assign('tea-dataOfHomeworkModify.html');
			},
			GetNewPages(){
				var classid = window.localStorage.getItem('TselectClass');//获取登录后的教师Username
				// var classdata=1;
				// window.localStorage.setItem('test',classdata);
				 axios.get(
				 		'http://172.81.214.138:8000/classes_student?cid='+classid)
				 	//成功返回
				 	.then(response => {
				 		console.log(response);
				 		if(response.data.state==1){
				 			//alert('获取成功');
									//console.log(response);
							
							for(let i=0;i<response.data.data.length;++i){
								//response.data.data[i].score_information.average=(int)response.data.data[i].score_information.average;
								response.data.data[i].score_information.average=parseInt( response.data.data[i].score_information.average);
								//console.log('ss'+i);
							}
							
							console.log(response.data.data);
							this.studatas=response.data.data;
							console.log(this.studatas);
				 		}
				 		else{
				 			alert('登录失败！');
				 		}
				 	})
				 	//失败返回
				 	.catch(error => {
				 		console.log(error);
				 	})
			}
			
		}
		
	})
</script>

</body>
</html>
